package com.algorithms.techniques;

import com.algorithms.techniques.RedBlackBinarySearchTree.Color;


public  class RBNode<K,V> extends Node<K,V> 
{
	private Color colour;

	public Color getColour() {
		return colour;
	}

	public void setColour(Color colour) {
		this.colour = colour;
	}
	public RBNode(K key,V value,Color colour)
	{
		setColour(colour);
		setKey(key);
		setValue(value);
	}
	public RBNode(Color colour)
	{
		setColour(colour);
		setKey(null);
		setValue(null);
	}
	public RBNode(Color colour,K  key,V  val)
	{
		setColour(colour);
		setKey(key);
		setValue(val);
	}
	
	public RBNode<K, V> getLeftChild() 
	{
		return (RBNode<K, V>) leftChild;
	}
	
	public RBNode<K, V> getRightChild() {
		return (RBNode<K, V>) rightChild;
	}
	
	public RBNode<K, V> getParent() {
		return (RBNode<K, V>) parent;
	}
	
	@Override
	public String toString() {
		K rChild=null;
		K lChild=null;
		if(rightChild!=null)
			rChild=rightChild.getKey();
		if(leftChild!=null)
			lChild=leftChild.getKey();
		return "key="+getKey() +",value="+ getValue() + "\tLeftChild="+lChild+"\tRightChild="+rChild ;
	}
}